package com.example.mobile2021606177cke;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class Rcy extends RecyclerView.Adapter<Rcy.holder> {
    List<Car>list;
    public Rcy(List<Car>list){
        this.list=list;
    }

    @NonNull
    @Override
    public Rcy.holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.tv_main_xml,null);
        holder holder=new holder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull Rcy.holder holder, int position) {
        Car qiche=list.get(position);
        holder.tv1.setText(qiche.getHuanjie());
        holder.tv2.setText(qiche.getGonxv());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    public class holder extends RecyclerView.ViewHolder{
        private TextView tv1;
        private TextView tv2;

        public holder(@NonNull View itemView) {
            super(itemView);
            this.tv1=itemView.findViewById(R.id.tv_main_1);
            this.tv2=itemView.findViewById(R.id.tv_main_2);
        }
    }
}
